package com.zimmur.app.mocolink.domain.util;


/**
 * 生成记录ID
 * @author Administrator
 *
 */
public final class IDWorkFactory {
	
	public static long getID(AppModuleEnum appEnum){
		int iModule = Integer.parseInt(appEnum.getModuleId());
		try {
			return CreateId.getId(iModule);
		} catch (Exception e) {
		}
		return 0;
	}
	
	private static class CreateId{
		private static IdWorker idWorker;
		public static long getId(int workerId){
			if(idWorker == null){
				idWorker = new IdWorker(workerId);
			}else{
				if(idWorker.getWorkerid() != workerId){
					idWorker = new IdWorker(workerId);
				}
			}
			
			return idWorker.nextId();
		}
	}
}

